package com.qike.duola.enums;

import com.qike.duola.vo.EnumList;

import java.util.ArrayList;
import java.util.List;

/**
 * 结算方式枚举
 * 0现款后货 1 月结月清 2 每月支付80%
 */
public enum PayTypeEnums {
    MONEY_FIRST                (0,"现款后货"),
    MONTH_CLEAR                      (1,"月结月清"),
    MONTH_PERCENTAGE                   (2,"每月支付70% 剩余砼款待该工程主体封顶后90天内全部付清。"),
    ;
    private Integer ecode;

    private String emsg;

    PayTypeEnums(Integer ecode, String emsg) {
        this.ecode = ecode;
        this.emsg = emsg;
    }

    public static List<EnumList> getEnumList(){
        List<EnumList> lists = new ArrayList<>();
        for (PayTypeEnums state : values()){
            EnumList enumList = new EnumList();
            enumList.setKey(state.getEcode());
            enumList.setValue(state.getEmsg());
            lists.add(enumList);
        }
        return lists;
    }

    public Integer getEcode() {
        return ecode;
    }

    public String getEmsg() {
        return emsg;
    }

    public static PayTypeEnums statOf(Integer ecode) {
        for (PayTypeEnums state : values())
            if (state.getEcode().equals(ecode))
                return state;
        return null;
    }
}
